#include "status.h"

void MonsterStatus_Feroc::attacked(int power, Monster* monster)
{
    int orgin_life = monster->getLife() ;
    if(orgin_life - power > 400)
    {
        //状态不变
        monster->setLife(orgin_life - power);
        std::cout << "怪物处于凶悍状态，对主角进行反击！" << std::endl;
    }
    else{
        monster->setStatus(MonsterStatus_Worr::instance());
        monster->getStatus()->attacked(power,monster);
    }
}

void MonsterStatus_Worr::attacked(int power,Monster* monster)
{
    int orgin_life = monster->getLife() ;
    if(orgin_life - power > 100)
    {
        //状态不变
        monster->setLife(orgin_life - power);
        std::cout << "怪物处于不安状态，对主角进行反击并呼叫支援！" << std::endl;
    }
    else{
        monster->setStatus(MonsterStatus_Fear::instance());
        monster->getStatus()->attacked(power,monster);
    }
}

void MonsterStatus_Fear::attacked(int power, Monster* monster)
{
     int orgin_life = monster->getLife() ;
    if(orgin_life - power > 0)
    {
        //状态不变
        monster->setLife(orgin_life - power);
        std::cout << "怪物处于恐惧状态，处于逃跑中！" << std::endl;
    }
    else{
        monster->setStatus(MonsterStatus_Dead::instance());
        monster->getStatus()->attacked(power,monster);
    }
}

void MonsterStatus_Dead::attacked(int power, Monster* monster)
{
     int orgin_life = monster->getLife() ;
    if(orgin_life - power > 0)
    {
        //状态不变
        monster->setLife(orgin_life - power);
    }
    std::cout <<"怪物死亡"<< std::endl;
}

void Monster::attacted(int power)
{
    this->m_status->attacked(power,this);
}
